<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title></title>
  <style>
    .light {

      height: 2px;
      width: 100%;
      background-color: lightgray;
      background-image: linear-gradient(to right, transparent 0, #0078d4 50%, transparent 100%);
      background-size: 20%;
      background-repeat: no-repeat;
      background-position-x: -20%;
    }

    .light.animate {
      animation: light-animate 2.5s linear infinite;
    }

    html,
    body {
      height: 100%;
    }

    @keyframes light-animate {
      from {
        background-position-x: -20%;
      }

      to {
        background-position-x: 120%;
      }
    }
  </style>
</head>

<body>
  <div class="light "></div>
  <script>
    const body = document.querySelector('body')
    const light = document.querySelector('.light')
    const boxSizing = body.clientWidth;

    body.addEventListener('mousemove', (e) => {
      
      light.style.backgroundPositionX = (e.clientX / (boxSizing)  ) * 100 + '%'
    })
  </script>
</body>

</html>